<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------

namespace app\common\model;

/**
* 用户模型
*/
class Member extends Base{

	protected $type = array(
		'uid'  => 'integer',
	);

    public function selfDetail(){
        if(is_login()){
            return $this->db()->where(array('uid'=>$_SESSION['index']['user_auth']['uid']))->find();
        }else{
            $this->redirect('index/index/login');
        }
    }

    public function tiaoj($data){
        $start = explode(',',$data['height']);
        //return $this->db()->where('shengao','between',[$start[0],$start[1]])->where(array('sex'=>$data['sex'],'xueli'=>$data['xueli']))->field('uid,shpic01')->paginate(6);
        return $this->db()->where('shengao','between',[$start[0],$start[1]])->where(array('sex'=>$data['sex'],'xueli'=>$data['xueli']))->paginate(6);
    }

    public function sgfy($start,$array,$page){
        $result = $this->db()->order("uid desc")->where('shengao','between',[$start[0],$start[1]])->where($array)->limit(($array['current']-1)*$page,$array['current']*$page)->select();
    }

    public function total($start,$array,$page){
        return ceil(count($this->db()->where('shengao','between',[$start[0],$start[1]])->order("uid desc")->where($array)->select())/$page);
    }

}